# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>

_realname=gtkada
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=25.0.0
pkgrel=2
pkgdesc="Ada bindings for the GTK+ graphical library. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
conflicts=("${MINGW_PACKAGE_PREFIX}-GtkAda-svn")
url="https://github.com/AdaCore/gtkada/"
msys2_references=(
  'aur: gtkada'
)
license=('spdx:GPL-3.0-or-later with GCC-exception-3.1')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gcc-ada"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-gprbuild"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/AdaCore/gtkada/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('bc6614072d0733bc112c4d0b0f0d6ff3fc0eb8021761efec8d9a00a1975dfec9')

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}"/${_realname}-${pkgver} "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  if [ -f Makefile ]; then
    make distclean
  fi
  CFLAGS+=" -Wno-int-conversion -Wno-implicit-function-declaration"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --disable-static \
    --disable-gtktest \
    --with-GL=no

  make || make -j1
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make -j1 DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}"${MINGW_PREFIX}/share/examples
  rm -rf "${pkgdir}"${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}
  cp -pf "${srcdir}"/${_realname}-${pkgver}/COPYING* \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}
}
